<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('表格传值给父页面')" />
    <th:block th:include="include :: bootstrap-select-css" />
</head>
<body class="gray-bg">
<div class="container-div">

    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>职工名称：</label>
                            <input type="text" name="userName"/>
                        </li>
                        <li>
                            <label>职工编码：</label>
                            <input type="text" name="loginName"/>
                        </li>

                        <li>
                            <label>手机：</label>
                            <input type="text" name="phonenumber"/>
                        </li>
                        <li>
                            <label>身份证：</label>
                            <input type="text" name="cardId"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>


<th:block th:include="include :: footer" />
<th:block th:include="include :: bootstrap-select-js" />
<script th:src="@{/js/common/add_grade.js}"></script>
<script th:inline="javascript">
    var statusDatas = [[${@dict.getType('sc_education_type')}]];
    var prefix = ctx + "school/personnel";

    $(function() {
        var options = {
            url: prefix + "/list",
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            modalName: "职工信息",
            columns: [{
                checkbox: true
            },
                {
                    field: 'userId',
                    title: '职工ID'
                },
                {
                    field: 'loginName',
                    title: '职工编码',
                    sortable: true
                },
                {
                    field: 'userName',
                    title: '姓名'
                },
                {
                    field: 'email',
                    title: '邮箱',
                    visible: false
                },
                {
                    field: 'phonenumber',
                    title: '手机'
                },
                {
                    field: 'cardId',
                    title: '身份证号'
                },
                {
                    field: 'education',
                    title: '学历',
                    align: 'center',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(statusDatas, value);
                    }
                },
                {
                    field: 'college',
                    title: '毕业院校'
                },
                {
                    title: '用户状态',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return statusTools(row);
                    }
                }
                ]
        };
        $.table.init(options);
    });

    /* 用户状态显示 */
    function statusTools(row) {
        if (row.status == 1) {
            return '<i class=\"fa fa-toggle-off text-info fa-2x\"></i> ';
        } else {
            return '<i class=\"fa fa-toggle-on text-info fa-2x\"></i> ';
        }
    }

    function submitHandler(index, layero) {
        var rows = $.table.selectFirstColumns();
        var studentName = $.table.selectColumns("userName");
        if (rows.length == 0) {
            $.modal.alertWarning("请至少选择一条记录");
            return;
        }
        $.modal.close();
    }
</script>
</body>
</html>